#ifndef MAINHANDLER_H
#define MAINHANDLER_H

#include <BLineArray>
#include <BViewer>
#include <BBillboard>
#include <BLine>
#include <BQuad>
#include <BCone>
#include <BSphere>
#include <BPicker>
#include <BSurface>
#include <BSphereHandler>

#include "DragHandler.h"

class MainHandler : public BSphereHandler
{
public:
	MainHandler();
	~MainHandler();

	void setGridSurface(BSurface* surface);
	BSurface* gridSurface() const;

protected:
	void drawPickedFeature(BRender& render, BPickItem* item);

protected:
	virtual void render(BRender& render);

	virtual void attachEvent(const BEvent& event);
	virtual void detachEvent(const BEvent& event);

	virtual void updateEvent(const BEvent& event);
	virtual void freshEvent(const BEvent& event);

	virtual bool keyDownEvent(const BKeyEvent& keyEvent);
	virtual bool keyUpEvent(const BKeyEvent& keyEvent);

	virtual bool mouseEnterEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseLeaveEvent(const BMouseEvent& mouseEvent);
	virtual bool mousePressEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseReleaseEvent(const BMouseEvent& mouseEvent);
	virtual bool mouseMoveEvent(const BMouseEvent& mouseEvent);

protected:
	BHolder<BNode>			_selectedNode;
	BHolder<BSurface>		_gridSurface;

	BHolder<DragHandler>	_dragHandler;

	BHolder<BPickItem>		_hoveredItem;
	BVector					_hoveredPoint;
	BHolder<BNode>			_hoveredNode;
	BHolder<BShape>			_hoveredShape;
	bool					_spaceShown;
	bool					_leftPressed;
	BLine					_linePressed;
	int						_transStep;

};

#endif